<?php
Zend_Loader::loadFile('../application/default/models/Common.php');
class Form_Hotel extends Zend_Form
{
    public function __construct($options=array())
    {
        parent::__construct($options);
        
    	Zend_Loader::loadClass('Roomcats', array('../application/admin/models/'));
        Zend_Loader::loadClass('Hotel', array('../application/admin/models/'));
        Zend_Loader::loadClass('Common', array('../application/default/models/'));
        $roomcat = new Roomcats();
        $hotel = new Hotel();
        $common = new Common();
        $roomcat_arr = $roomcat->listroomcats();
        $amenity_arr = $hotel->getAminities();
        $country_arr = $common->getCountries();
        $city_arr = $common->getCities();
        
        if(!empty($options))
		{
    		if($options['action'] == "edit")
    		{ 
        		$hotel_id = $options['hotel_id'];
    			$city_arr_by_hotel = $hotel->getCityByHotelId($hotel_id);
    		}
		}		
        $this->setMethod('post');
        $this->addPrefixPath('Lion_Form_Element', '../library/Form/Element/', 'element');

        

        $this->addElement('text', 'hotel_title', array(
        'label'      => 'Hotel Name:',
        'filters'    => array('StringTrim'),
        'class'			 => 'input-2',
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 50))
        )
        ));

        $hotel_country= new Zend_Form_Element_Select('hotel_country');
        $hotel_country ->setLabel('Hotel Country');
        $hotel_country->setOptions(array('class'=>'input-2'));
        $hotel_country->addMultiOption("", "Select Country");
        foreach ($country_arr as $country_entry) {
            $hotel_country->addMultiOption($country_entry['country_id'], $country_entry['country_name']);
        }
        
        $hotel_country->setAttrib('onChange', 'return getCity();');
        
        $this->addElement($hotel_country);

        $hotel_city= new Zend_Form_Element_Select('hotel_city');
        $hotel_city ->setLabel('Hotel City');
        $hotel_city->setOptions(array('class'=>'input-2'));
        
        if(!empty($options))
        {
	        if($options['action'] == "edit")
	        {
	        	$hotel_city->addMultiOption("", "Select City");
	        	foreach ($city_arr_by_hotel as $city_entry_by_hotel) {
	            	$hotel_city->addMultiOption($city_entry_by_hotel['city_id'], $city_entry_by_hotel['city_name']);
	        	}
	        } else {
	        	$hotel_city->addMultiOption("", "Select City");
	        }	
        }    
        $this->addElement($hotel_city);
        
        $hotel_content = $this->addElement('textarea','hotel_description', array('label' => 'Hotel Description', 'rows' => '5' ));

       	$hotel_facility_en = $this ->addElement('formRTE', 'hotel_facility_en',
    				array('label' =>'Facilities(english):',
    					'validators' =>array(
    					array('validator' =>'StringLength', 'options' =>array(0, 1000))
    				),
		));
		
		$hotel_facilitys_ru = $this ->addElement('formRTE', 'hotel_facility_ru',
    				array('label' =>'Facilities(russian):',
    					'validators' =>array(
    					array('validator' =>'StringLength', 'options' =>array(0, 1000))
    				),
		));
		
		$this->addElement('text', 'contact_email', array(
        'label'      => 'Contact Email:',
        'filters'    => array('StringTrim'),
        'class'			 => 'input-2',
        'size' => 100,
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 50))
        )
        ));

        $this->addElement('text', 'hotel_phone', array(
        'label'      => 'Hotel Phone:',
        'filters'    => array('StringTrim'),
        'class'			 => 'input-2',
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 100))
        )
        ));

        $this->addElement('text', 'hotel_fax', array(
        'label'      => 'Hotel Fax:',
        'filters'    => array('StringTrim'),
        'class'			 => 'input-2',
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 100))
        )
        ));

        $this->addElement('text', 'hotel_skype', array(
        'label'      => 'Hotel Skype:',
        'required'   => false,
        'filters'    => array('StringTrim'),
        'class'			 => 'input-2',
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 100))
        )
        ));

		$this->addElement('text', 'no_rooms', array(
        'label'      => 'No. of Rooms:',
        'required'   => false,
        'filters'    => array('StringTrim'),
        'class'			 => 'input-2',
        'validators' => array(
        array('validator' => 'StringLength', 'options' => array(0, 20))
        )
        ));
        
        $status = new Zend_Form_Element_Select('is_Enabled');
        $status ->setLabel('Status')
		 			 ->addMultiOptions(array(
		 			    '' => 'Select Status',            
						1 => 'Published',
						0 => 'Unpublished'));
		$status->setOptions(array('class'=>'input-2'));				
		$this->addElement($status);
		
		if(!empty($options))
		{
    		if($options['action'] == "edit")
    		{ 
        	   	$this->addElement('hidden', 'hotel_id', array(	            
        	            'filters'  => array('int'),
        	            'class'	   => 'hidden',
        	            'value'    => $options['hotel_id'],	            
        	    ));
    		}
		}	
    }    
}
